package com.raycloud.robot.utils;

import com.raycloud.robot.consts.DateConstant;
import java.util.Objects;
import java.time.ZoneId;
import java.time.Instant;
import java.time.LocalDateTime;

public class DateUtil{
    public static LocalDateTime longToLocalDateTime(final Long time){
        if(null==time){
            return null;
        }
        final Instant instant=Instant.ofEpochMilli(time);
        final ZoneId zoneId=ZoneId.systemDefault();
        return instant.atZone(zoneId).toLocalDateTime();
    }
    public static String longToStr(final Long time){
        if(Objects.isNull(time)){
            return null;
        }
        final LocalDateTime localDateTime=LocalDateTime.ofInstant(Instant.ofEpochMilli(time),ZoneId.systemDefault());
        return localDateTime.format(DateConstant.DATE_TIME_FILE_NAME_FORMATTER);
    }
}
